{ INFORMATICS.MCCME.RU
  Problem statement: http://informatics.mccme.ru/moodle/mod/statements/view3.php?chapterid=1467
  Verdict: Accepted
}
uses SysUtils, Math;
 
var
	d,m,y,cc:longint;
 
function bis(y:longint):boolean;
begin
result:=(y mod 400=0) or ((y mod 4=0) and (y mod 100<>0));
end;
 
begin
reset(input,'input.txt');
rewrite(output,'output.txt');
read(d,m,y);
if (m=4) or (m=6) or (m=9) or (m=11) then cc:=30 else
if m=2 then begin
	cc:=28;
	if bis(y) then inc(cc);
end else cc:=31;
inc(d,2);
if d>cc then begin
	dec(d,cc);
	inc(m);
	if m>12 then begin
		m:=1;
		inc(y);
	end;
end;
write(d,' ',m,' ',y); 
end.